﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>显示一个确认框</title>
</head>
<body>
    <p>单击按钮，显示确认框</p>
    <button onclick="myFunction()">确认</button>
    <p id="demo"></p>
    <script>
        function myFunction() {
            let x;
            let r = confirm("按下按钮！");
            if (r === true) {
                x = "你按下了【确认】按钮！";
            } else {
                x = "你按下了【取消】按钮！";
            }
            document.getElementById("demo").innerHTML = x;
        }
    </script>
</body>
</html>